$.extend($.gritter.options, { 
    position: 'bottom-right', 
	fade_in_speed: 'medium', 
	fade_out_speed: 2000,
	time: 6000
});

var showGritter = function(options) {
	if (options != undefined) {
		var caption = 'Notification';

		if (options.title != undefined) {
			if (options.title != null) caption = options.title;
		}

		var message = '';

		if (options.text != undefined) {
			if (options.text != null) message = options.text;
		}

		var icon = 'info';
		
		if (options.icon != undefined) {
			if (options.icon != null) {
				if (options.icon.trim().toLowerCase() == 'info' ||
					options.icon.trim().toLowerCase() == 'warning' ||
					options.icon.trim().toLowerCase() == 'error') icon = options.icon;
			}
		}

		var img = app.baseUrl() + 'img/' + icon + '-metro.png';

		$.gritter.add({
			title: caption,
			text: message,
			image: img
		});
	}
};

var errorGritter = function(options) {
	var caption = '';
	var message = '';

	if (options != undefined) {
		if (options.title != undefined) {
			if (options.title != null) caption = options.title;
		}

		if (options.text != undefined) {
			if (options.text != null) message = options.text;
		}
	}

	showGritter({
		title: caption,
		text: message,
		icon: 'error'
	});
};

var infoGritter = function(options) {
	var caption = '';
	var message = '';

	if (options != undefined) {
		if (options.title != undefined) {
			if (options.title != null) caption = options.title;
		}

		if (options.text != undefined) {
			if (options.text != null) message = options.text;
		}
	}

	showGritter({
		title: caption,
		text: message
	});
};

var warningGritter = function(options) {
	var caption = '';
	var message = '';

	if (options != undefined) {
		if (options.title != undefined) {
			if (options.title != null) caption = options.title;
		}

		if (options.text != undefined) {
			if (options.text != null) message = options.text;
		}
	}

	showGritter({
		title: caption,
		text: message,
		icon: 'warning'
	});
};